/*  1:   */ package org.intellij.plugins.relaxNG.xml.dom.impl;
/*  2:   */ 
/*  3:   */

import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
import com.intellij.psi.xml.XmlFile;
import com.intellij.util.xml.*;
import org.intellij.plugins.relaxNG.references.FileReferenceUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */ 
/* 17:   */ public class RngHrefConverter
/* 18:   */   extends Converter<XmlFile>
/* 19:   */   implements CustomReferenceConverter<XmlFile>
/* 20:   */ {
/* 21:   */   public XmlFile fromString(@Nullable @NonNls String paramString, ConvertContext paramConvertContext)
/* 22:   */   {
/* 23:37 */     if (paramString != null)
/* 24:   */     {
/* 25:38 */       GenericAttributeValue localGenericAttributeValue = (GenericAttributeValue)paramConvertContext.getInvocationElement();
/* 26:39 */       PsiReference[] arrayOfPsiReference = createReferences(localGenericAttributeValue, localGenericAttributeValue.getXmlAttributeValue(), paramConvertContext);
/* 27:40 */       if (arrayOfPsiReference.length > 0)
/* 28:   */       {
/* 29:41 */         PsiElement localPsiElement = arrayOfPsiReference[(arrayOfPsiReference.length - 1)].resolve();
/* 30:42 */         if ((localPsiElement instanceof XmlFile)) {
/* 31:43 */           return (XmlFile)localPsiElement;
/* 32:   */         }
/* 33:   */       }
/* 34:   */     }
/* 35:47 */     return null;
/* 36:   */   }
/* 37:   */   
/* 38:   */   public String toString(@Nullable XmlFile paramXmlFile, ConvertContext paramConvertContext)
/* 39:   */   {
/* 40:51 */     return paramXmlFile == null ? null : paramXmlFile.getName();
/* 41:   */   }
/* 42:   */   
/* 43:   */   @NotNull
/* 44:   */   public PsiReference[] createReferences(GenericDomValue<XmlFile> paramGenericDomValue, PsiElement paramPsiElement, ConvertContext paramConvertContext)
/* 45:   */   {
/* 46:56 */     String str = paramGenericDomValue.getStringValue();
/* 47:57 */     if ((str == null) || (paramPsiElement == null))
/* 48:   */     {
/* 49:58 */       PsiReference[] tmp20_17 = PsiReference.EMPTY_ARRAY;
/* 50:58 */       if (tmp20_17 == null) {
/* 51:58 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/plugins/relaxNG/xml/dom/impl/RngHrefConverter", "createReferences" }));
/* 52:   */       }
/* 53:58 */       return tmp20_17;
/* 54:   */     }
/* 55:60 */     FileReferenceSet localFileReferenceSet = FileReferenceSet.createSet(paramPsiElement, false, false, false);
/* 56:61 */     if (localFileReferenceSet != null)
/* 57:   */     {
/* 58:62 */       PsiReference[] tmp83_80 = FileReferenceUtil.restrict(localFileReferenceSet, FileReferenceUtil.byNamespace("http://relaxng.org/ns/structure/1.0"), Boolean.valueOf(true));
/* 59:62 */       if (tmp83_80 == null) {
/* 60:62 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/plugins/relaxNG/xml/dom/impl/RngHrefConverter", "createReferences" }));
/* 61:   */       }
/* 62:62 */       return tmp83_80;
/* 63:   */     }
/* 64:64 */     PsiReference[] tmp121_118 = PsiReference.EMPTY_ARRAY;
/* 65:64 */     if (tmp121_118 == null) {
/* 66:64 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/plugins/relaxNG/xml/dom/impl/RngHrefConverter", "createReferences" }));
/* 67:   */     }
/* 68:64 */     return tmp121_118;
/* 69:   */   }
/* 70:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.xml.dom.impl.RngHrefConverter

 * JD-Core Version:    0.7.0.1

 */